/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidade;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author master
 */
@Entity
@Table(name = "questoes")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Questoes.findAll", query = "SELECT q FROM Questoes q"),
    @NamedQuery(name = "Questoes.findById", query = "SELECT q FROM Questoes q WHERE q.id = :id"),
    @NamedQuery(name = "Questoes.findByPergunta", query = "SELECT q FROM Questoes q WHERE q.pergunta = :pergunta")})
public class Questoes implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Size(max = 2147483647)
    @Column(name = "pergunta")
    private String pergunta;
    @OneToMany(mappedBy = "questao")
    private List<Questionario> questionarioList;
    @JoinColumn(name = "questao", referencedColumnName = "id")
    @ManyToOne
    private Tipo questao;

    public Questoes() {
    }

    public Questoes(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getPergunta() {
        return pergunta;
    }

    public void setPergunta(String pergunta) {
        this.pergunta = pergunta;
    }

    @XmlTransient
    public List<Questionario> getQuestionarioList() {
        return questionarioList;
    }

    public void setQuestionarioList(List<Questionario> questionarioList) {
        this.questionarioList = questionarioList;
    }

    public Tipo getQuestao() {
        return questao;
    }

    public void setQuestao(Tipo questao) {
        this.questao = questao;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Questoes)) {
            return false;
        }
        Questoes other = (Questoes) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidade.Questoes[ id=" + id + " ]";
    }
    
}
